//
//  CashierNewSearchCell.m
//  TryShopping
//
//  Created by LiYinDi on 16/6/7.
//  Copyright © 2016年 RuiBen. All rights reserved.
//

#import "CashierNewSearchCell.h"

@implementation CashierNewSearchCell

- (void)awakeFromNib {
    [self setAutoLayout];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(CashierNewSearchDataModel *)model
{
    [_productImageView setImageWithURL:[NSURL URLWithString:model.imageUrlFull]];
    _productNameLabel.text=model.specName;
    _productStockLabel.text=[NSString stringWithFormat:@"%d",[model.specInv intValue]];
    _productPriceLabel.text=[NSString stringWithFormat:@"¥%@",[Global floatConvertPercentile:[model.salePrice floatValue]]];
   
}
-(void)setAutoLayout
{
    [_productImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(13);
        make.width.equalTo(@80);
        make.height.equalTo(@80);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    [_productNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_productImageView.mas_right).with.offset(10);
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.top.equalTo(_productImageView.mas_top).with.offset(5);
        make.bottom.equalTo(_productStockTagLabel.mas_top).with.priorityLow();
    }];
    [_productStockTagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_productNameLabel.mas_left);
        make.width.equalTo(@30);
        make.height.equalTo(@21);
        make.bottom.equalTo(_productImageView.mas_bottom).with.offset(-8);
    }];
    [_productStockLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_productStockTagLabel.mas_right);
        make.right.equalTo(_productPriceLabel.mas_left).with.priorityLow();
        make.height.equalTo(@21);
        make.bottom.equalTo(_productStockTagLabel.mas_bottom);
    }];
    [_productPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-12);
        make.left.equalTo(_productStockLabel.mas_right);
        make.height.equalTo(@21);
        make.centerY.equalTo(_productStockLabel.mas_centerY);
    }];
    
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.left.equalTo(self.mas_left).with.offset(10);
        make.height.equalTo(@1);
        make.bottom.equalTo(self.mas_bottom);
    }];

}

@end
